﻿using log4net;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Luck
{
    public partial class JXOutsideSystemFrm : Form
    {
        private static ILog _log = LogManager.GetLogger(typeof(JXOutsideSystemFrm));
        public JXOutsideSystemFrm()
        {
            InitializeComponent();
            timer1.Stop();
        }
        string[] NameList = new string[25] { "AAA", "BBB", "CCC", "DDD", "EEE", "FFF", "GGG", "HHH", "JJJ", "KKK", "LLL", "QQQ", "WWW", "TTT", "RRR", "YYY", "UUU", "III", "OOO", "PPP", "ZZZ", "XXX", "VVV", "NNN", "MMM" };
        Random r = new Random();
        int i;
        string selected = "";
        List<int> LuckyNum = new List<int>();    //lucky的幸运号码
        int selectedNum = 0;
        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Start();        
        }
        private void button2_Click(object sender, EventArgs e)
        {
            timer1.Stop();
            while (LuckyNum.Contains(i))
            {
                i = r.Next(0, 25);                      
            }
            if (selectedNum < 8)
            {
                //selected += i.ToString();
                LuckyNum.Add(i);
                selectedNum++;
                lbLuckyList.Text = NameList[i];
                if (selectedNum == 1)
                {
                    lbTedeng.Text = NameList[i];
                    _log.Info(lbTedeng.Text.ToString());
                }
                else if (selectedNum >= 2 && selectedNum <= 3)
                {
                    lbYideng.Text += NameList[i] + "     ";
                    _log.Info(lbYideng.Text.ToString());
                }
                else if (selectedNum >= 4 && selectedNum <= 8)
                {
                    lbErdeng.Text += NameList[i] + "     ";
                    _log.Info(lbErdeng.Text.ToString());
                }
            }
            if(selectedNum ==8)
            {
                _log.Info("已经全部抽取完毕");
                lbLuckyList.Text = "已经全部抽取完毕";            
                button1.Enabled = false;
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {     
            i = r.Next(0, 25);  
            lbLuckyList.Text = NameList[i];
        }       
    }
}
